import React, { PureComponent } from 'react';
import { Icon } from 'antd-mobile';
import { connect } from 'react-redux';
import SysUtil from '../../core/utils/SysUtil';
import Router from 'next/router';

class LeftContentView extends PureComponent
{
    constructor(props)
    {
        super(props);
        this.state = {
            isMenu: SysUtil.getUrlParameter('isMenu') === 'true' ? true : false
        };
    }
    componentDidMount()
    {
        this.goHome=this.goHome.bind(this);
    }
    render() {
        if (this.state.isMenu) {
            return (
                <img className='homeMine' src={require('../../assets/images/home.png')} alt=''/>
            );
        }else{
            return (
                <Icon type="left"/>
            );
        }
    }
    goHome(){
        if(this.props.goBackAction()){
            this.props.dispatch(this.props.goBackAction());
        }
        if (this.state.isMenu) {
            this.props.history.replace('/');
        } else {
            // this.props.history.goBack();
            Router.back();
        }
    }
}

const mapStateToProps = function(state, ownProps)
{
    return {
    };
};

LeftContentView = connect(mapStateToProps, null, null, {withRef: true})(LeftContentView);

export default LeftContentView;
